package de.koller.balance.scene.universe;

import de.koller.aframe.gl.ATexture;
import de.koller.aframe.gl.Camera;
import de.koller.balance.render.BRenderExt;
import de.koller.oceanFramework.math.RVec3;
import java.util.Random;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Sphere;

public class UniverseScene extends BRenderExt {
		
	private final RVec3 lightVector = new RVec3( 1f, .2f, .8f );
	private final RVec3 eyevector = new RVec3( 0, 0, 1f );
	private Random rnd = new Random();
	private ATexture surface = new PlanetTexture();
	
	public final Camera camera = new Camera();

	public UniverseScene() {
		
	}

	@Override
	protected void init() {
		super.init();
		
		
	}
	
	private void initCamera() {
		commonUses.setUpPerspective();
		
		GL11.glPushMatrix();
		camera.position.set( 0, 2, 0 );
		camera.setLookAt( new RVec3( 0, 0, 0 ) );
		camera.up.set( 0, 0, 1 );
		camera.transformGL();
	}
	
	private void popCamera() {
		GL11.glPopMatrix();
	}

	private float r = 0;
	private float s = 0;
	
	@Override
	public void renderSzene() {
		initCamera();
		
//		GL11.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE );
//		GL11.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE );
		
		GL11.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT );
		GL11.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT );
		
		GL11.glPushMatrix();
	
		//if( !renderLight || !broot.quality ) {
		GL11.glRotatef( r += 0.1f, 1, 0, 0 );
		GL11.glRotatef( s += 0.06f, 0, 0, 1 );
				
			surface.bindAnisotrophic();
			Sphere s = new Sphere();
			s.setTextureFlag( true );
			s.draw( 1, 36, 18 );
		//}
		
		GL11.glPopMatrix();
		
		popCamera();
	}
	
}
